package com.atguigu.lease.common.sms;

import com.aliyun.dysmsapi20170525.Client;
import com.aliyun.teaopenapi.models.Config;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author :冉佳
 * @CreateTime: 2025-02-11
 * @Description:
 * @Version:1.0
 **/
@Configuration// 阿里云的配置类 将客户端对象纳入ioc      属性配置类(读取配置文件)
public class AliyunSmsConfiguration {

    @Autowired
    private AliyunSMSProperties aliyunSMSProperties;
    @Bean
    public Client client(){

        try {
            Config config = new Config();
            config.setEndpoint(aliyunSMSProperties.getEndpoint()).
                    setAccessKeyId(aliyunSMSProperties.getAccessKeyId()).
                    setAccessKeySecret(aliyunSMSProperties.getAccessKeySecret());
            return new Client(config);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

}
